<script>
	import config from './config'
	import store from '@/store'
	import {
		getToken
	} from '@/utils/auth'
	import DB from "@/utils/sqlite.js";
	import checkUpdate from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
	export default {
		onLaunch: function() {
			console.log("App启动成功");
			this.initApp()
			this.openSQL()
		},
		onShow() {
			checkUpdate();
		},
		mounted() {
			
		},
		methods: {
			// 打开数据库
			openSQL() {
				// 这个是查询有没有打开数据库
				let open = DB.isOpen();
				console.log("数据库状态", open ? "开启" : "关闭");
				if (!open) {
					DB.openSqlite()
						.then(res => {
							 // this.$modal.showToast('本地数据库已打开')
						})
						.catch(error => {
							console.log("数据库开启失败");
						});
				}
			},
			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()
				// 检查用户登录状态
				//#ifdef H5
				this.checkLogin()
				//#endif

			},
			initConfig() {
				this.globalData.config = config
			},
			checkLogin() {
				if (!getToken()) {
					// this.$tab.reLaunch('/pages/login') 
				}
			}
		}
	}
</script>

<style lang="scss">
	@import '@/static/scss/index.scss';
	@import 'uview-ui/index.scss'
</style>
